home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2220 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: news.ov.com!news
  2. From: glenn@ov.com (Fletcher.Glenn@ov.com)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Pound defines
  5. Date: 19 Jan 1996 22:27:33 GMT
  6. Organization: OpenVision
  7. Message-ID: <4dp5sl$9t8@spanky.pls.ov.com>
  8. References: <4dgquf$fuq@bmerhc5e.bnr.ca>
  9. Reply-To: glenn@ov.com
  10. NNTP-Posting-Host: foghorn.pls.ov.com
  11.  
  12. In article fuq@bmerhc5e.bnr.ca, studnt1@bmerhe78.bnr.ca (Jean Giblin ) writes:
  13. >hello everyone:
  14. >
  15. >    I was wondering if anybody out there knows about a C command that prints the
  16. >the name of the define when given the number. Example:
  17. >
  18. > #define MAX 20
  19. >
  20. >when given 20 it will return max.
  21. >
  22. >I thought a command existed, but I could be wrong.  Please respond to this newgroup,
  23. >and not my e-mail address.
  24. >
  25. >    Thanks
  26. >        Nick
  27.  
  28.  
  29. All of the directives that start with # are C pre-processor directives.  These
  30. directives are all resolved before compiling begins.  This means for your
  31. example that all references to MAX are replaced with 20.  To see what I mean,
  32. see if your compiler will output the actual source after pre-processing.
  33. On most UNIX compilers the command is "cc -E filename.c"
  34.  
  35. Given that the defines disappear before compiling, there is no way to work
  36. backwards from the value.  Besides, how would one handle the following?
  37.  
  38. #define FOO 20
  39. #define BAR 20
  40. #define BLECH 20
  41.  
  42.             Fletcher.Glenn@ov.com
  43.  
  44.  
  45.